﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Data;
using ZLDC.Common.Estate;
using ZLDC.Topo.Model.Estate;

namespace ZLDC.Topo.BLL.Estate
{
                public class AuthorizationBLL
    {
                                                public static AuthorizationInfo p_authorization_detail(int deptId)
        {
            using (_Database db = new _Database("estate"))
            {
                return ZLDC.DAL.Estate.AuthorizationDAL.p_authorization_detail(deptId, db);
            }
        }

                                                        public static DataTable p_authorization_detail_table(int typeid, int deptId)
        {
            DataTable dt = null;

            using (_Database db = new _Database("estate"))
            {
                dt = ZLDC.DAL.Estate.AuthorizationDAL.p_authorization_detail_table(typeid, deptId, db);
            }

            return dt;
        }

                                                                public static string p_authorization_delete(int typeid, int deptId, string id)
        {
            string outmsg = "";

            using (_Database db = new _Database("estate"))
            {
                ZLDC.DAL.Estate.AuthorizationDAL.p_authorization_delete(typeid, deptId, id, out outmsg, db);
            }

            return outmsg;
        }

                                                                                                                                                        public static string p_authorization_save(int deptId, string dept, string useage, string areas, string areasTel, string areasFollow, string areasInfo, string estates, string estatesTel, string estatesFollow, string estatesInfo, string cusTel, string cusFollow, string mark1)
        {
            string outmsg = "";
            int newid = 0;

            using (_Database db = new _Database("estate"))
            {
                ZLDC.DAL.Estate.AuthorizationDAL.p_authorization_save(deptId, dept, useage, areas, areasTel, areasFollow, areasInfo, estates, estatesTel, estatesFollow,
                    estatesInfo, cusTel, cusFollow, mark1, "", "", "", "", out outmsg, out newid, db);
            }

            return outmsg;
        }

        public static string p_authorization_save1(int deptId, string dept, string areas)
        {
            string outmsg = "";
            int newid = 0;

            using (_Database db = new _Database("estate"))
            {
                ZLDC.DAL.Estate.AuthorizationDAL.p_authorization_save1(deptId, dept,areas, out outmsg, out newid, db);
            }

            return outmsg;
        }

        public static string p_saveusage(int deptId, string dept, string useage,string mark1) 
        {
            string outmsg = "";
            int newid = 0;

            using (_Database db = new _Database("estate")) 
            {
                ZLDC.DAL.Estate.AuthorizationDAL.p_saveusage(deptId, dept, useage, mark1, out outmsg, out newid, db);
            }
            return outmsg;
        }

        public static string GetParentSubDeptList(string deptid)
        {
            string parentSubDeptList = string.Empty;

            using (_Database db = new _Database("estate"))
            {
                parentSubDeptList = ZLDC.DAL.Estate.AuthorizationDAL.GetAreaCust(deptid, db);
            }

            return parentSubDeptList;
        }

                                                public static int GetMark1FromAuthorization(int deptid)
        {
            int mark1 = 0;

            AuthorizationInfo info = p_authorization_detail(deptid);

            if (info != null && info.ID > 0)
                mark1 = _Convert.ToInt(info.Mark1, 0);

            return mark1;
        }
    }
}
